Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error "sample may not include multiple panels" for *Durbin Watson test

    Hi. I am using panel data and I want to test for autocorrelation in my dataset. My panel identifier is a consultant code, which is unbalanced. My time variable, which is the week number, has gaps. That is, for some weeks I may have no data for some consultants. Each consultant does have at least four panel observations. However, I still get the "sample may not include multiple panels" on running the Durbin Watson test for autocorrelation.

    Could someone please help me here?


    Code:
    tsset week_gen consultant_code
           panel variable:  week_gen (unbalanced)
            time variable:  consultant_~e, 1 to 100, but with gaps
                    delta:  1 unit
    
    
    
    . reg OCbyWeek consultant_code i.week_gen i.sex i.strata_campus i.age_group
    
          Source |       SS           df       MS      Number of obs   =     1,949
    -------------+----------------------------------   F(28, 1920)     =      5.39
           Model |    2771.914        28  98.9969285   Prob > F        =    0.0000
        Residual |  35236.5314     1,920  18.3523601   R-squared       =    0.0729
    -------------+----------------------------------   Adj R-squared   =    0.0594
           Total |  38008.4454     1,948  19.5115223   Root MSE        =     4.284
    
    ---------------------------------------------------------------------------------
           OCbyWeek |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
    consultant_code |  -.0100498   .0035934    -2.80   0.005    -.0170971   -.0030024
                    |
           week_gen |
                 2  |   .6503219   .6654128     0.98   0.329    -.6546859     1.95533
                 3  |   1.482073   .6634909     2.23   0.026     .1808339    2.783311
                 4  |   .3945532   .6652723     0.59   0.553    -.9101791    1.699285
                 5  |   .5017673   .6580053     0.76   0.446    -.7887129    1.792248
                 6  |   .9866308   .6597859     1.50   0.135    -.3073415    2.280603
                 7  |   .6783259   .6562974     1.03   0.301    -.6088048    1.965457
                 8  |   .6901914   .6674288     1.03   0.301    -.6187701    1.999153
                 9  |  -.0369435   .6580267    -0.06   0.955    -1.327466    1.253579
                10  |   .7780871    .651276     1.19   0.232    -.4991956     2.05537
                11  |     .09302   .6545462     0.14   0.887    -1.190676    1.376716
                12  |   1.005607   .6580206     1.53   0.127     -.284903    2.296117
                13  |   .2673806   .6652555     0.40   0.688    -1.037319     1.57208
                14  |   .5045686   .6545791     0.77   0.441    -.7791923    1.788329
                15  |   .6189594   .6599452     0.94   0.348    -.6753253    1.913244
                16  |   .4646031   .6581353     0.71   0.480    -.8261321    1.755338
                17  |  -.3828458   .6617966    -0.58   0.563    -1.680762      .91507
                18  |   .9784346   .6496361     1.51   0.132    -.2956319    2.252501
                19  |    1.06098   .6496156     1.63   0.103    -.2130461    2.335006
                20  |   1.104494   .6512457     1.70   0.090    -.1727292    2.381717
                21  |   .8141989    .658012     1.24   0.216    -.4762944    2.104692
                22  |  -.8659594    .657982    -1.32   0.188    -2.156394     .424475
                    |
                sex |
                 M  |  -.1528916   .2051885    -0.75   0.456    -.5553073    .2495241
                    |
      strata_campus |
         1  |   1.118929   .2684115     4.17   0.000     .5925202    1.645338
         2  |   2.745076     .38681     7.10   0.000     1.986464    3.503688
     3  |     1.0982   .3883027     2.83   0.005     .3366602    1.859739
                    |
          age_group |
                 2  |   .9321409   .2336606     3.99   0.000     .4738857    1.390396
                 3  |   2.739329   .3225472     8.49   0.000      2.10675    3.371909
                    |
              _cons |   .9975297    .569755     1.75   0.080    -.1198739    2.114933
    ---------------------------------------------------------------------------------
    
    . estat dwatson
    sample may not include multiple panels
    r(459);
    
    .

  • #2
    The Durbin-Watson D test is not designed for panel data. See xtserial from the Stata Journal instead.

    Code:
    SJ-3-2  st0039  . . Testing for serial correlation in linear panel-data models
            (help xtserial if installed)  . . . . . . . . . . . . .  D. M. Drukker
            Q2/03   SJ 3(2):168--177
            test for serial correlation in random- or fixed-effects
            one-way models that can be applied under general conditions
    Code:
    findit xtserial
    Last edited by Andrew Musau; 20 Jun 2023, 13:14.

    Comment


    • #3
      How many consultants are in the data set? Looks like maybe 100 or so?

      Comment


      • #4
        Andrew Musau Thanks. I wasn't aware of that

        Jeff Wooldridge Yes, there are 100 consultants. Does that have a bearing on anything here?

        Comment


        • #5
          A important detail here is that the tsset call looks quite the wrong way round. The panel identifier should be mentioned first and the time variable second.

          Another important detail is that consultant code is not plausible as a counted or measured predictor in the regression. Whether week may be so considered is more up in the air.

          Comment

          Working...
          X